package com.jason.dao.user;

import org.springframework.stereotype.Repository;

import com.jason.dao.BaseDao;
import com.jason.entity.UserEntity;
import com.jason.util.Page;

@Repository
public class UserDao extends BaseDao {
	public void getAll(Page<UserEntity> page) {
		StringBuffer sql_all = new StringBuffer("select * ");
		sql_all.append("from userinfo where id>=(select max(id) from (select id from userinfo order by id limit ")
				.append(page.getFirst() - 1)
				.append(",1) as user ) order by id limit ")
				.append(page.getPageSize());
		String totalCountSql = "select count(1) from userinfo";
		page.setTotalCount(jdbcTemp.queryForInt(totalCountSql));
		logger.info("jdbctemp:" + totalCountSql);
		page.setResult(jdbcTemp.query(sql_all.toString(), new UserEntity()));
		logger.info("jdbctemp:" + sql_all);
	}

}
